
#ifndef _GL_CORE_
#define _GL_CORE_

#include <GLES3/gl3.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "plugin_common.h"
#include "shader.h"

#include <string>
class EGLCore;
struct thread_data {
    void *window;
    int w;
    int h;
    char *id;
    EGLCore *eglCore;
};
class EGLCore {
  public:
    EGLCore(std::string &id) : id_(id){};
    void GLContextInit(void *window, int w, int h, char *id);
    void DrawCube();
    void DrawTransform();

    static void *start_render(void *threadarg) {
        struct thread_data *my_data;
        my_data = (struct thread_data *)threadarg;
        my_data->eglCore->GLContextInit(my_data->window, my_data->w, my_data->h, my_data->id);
        LOGI("zbclog sayhello eglcore w %{public}d h %{public}d w %{public}s", my_data->w, my_data->h, my_data->id);
        pthread_exit(NULL);
        //        return 0;
    }

    static void *drawT(void *threadarg) {
        struct thread_data *my_data;

        my_data = (struct thread_data *)threadarg;
        my_data->eglCore->DrawCube();
        pthread_exit(NULL);
        //        return 0;
    }

  public:
    std::string id_;
    int width_;
    int height_;

  private:
    EGLNativeWindowType mEglWindow = 0;
    EGLDisplay mEGLDisplay = EGL_NO_DISPLAY;
    EGLConfig mEGLConfig = nullptr;
    EGLContext mEGLContext = EGL_NO_CONTEXT;
    EGLContext mSharedEGLContext = EGL_NO_CONTEXT;
    EGLSurface mEGLSurface = nullptr;
};

#endif // OPENGL的核心模块
